unit Unit14; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, db, sqldb,
  DbCtrls, StdCtrls, Buttons, Unit1;

type

  { TForm14 }

  TForm14 = class(TForm)
    Datasource1: TDatasource;
    DBComboBox1: TDBComboBox;
    Label1: TLabel;
    SQLQuery1: TSQLQuery;
    procedure DBComboBox1Select(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormShow;
  private
    { private declarations }
  public
    flia_productos : string;
  end; 

var
  Form14: TForm14; 

implementation

uses
  Unit11;

{ TForm14 }

procedure TForm14.FormShow;
begin
  if SQLQuery1.Active = True then
    SQLQuery1.Close;
    
  SQLQuery1.Database := Form1.PQConnection1;
  SQLQuery1.Transaction := Form1.SQLTransaction1;
  SQLQuery1.SQL.Text := 'select fmp_nombre from familia_producto';

  SQLQuery1.Open;

  DBComboBox1.DataField := 'fmp_nombre';
  DBComboBox1.Clear;

  while not SQLQuery1.EOF do
  begin
    DBComboBox1.Items.Add(SQLQuery1.Fields[0].AsString);
    SQLQuery1.Next;
  end;
  
  DBComboBox1.Text := '';
  
  DBComboBox1.SetFocus;
end;

procedure TForm14.DBComboBox1Select(Sender: TObject);
begin
  flia_productos := DBComboBox1.Text;
  Close;
end;

procedure TForm14.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  if SQLQuery1.Active = True then
    SQLQuery1.Close;
end;

initialization
  {$I unit14.lrs}

end.

